﻿using System;

namespace Freedom.Common.Collections
{
    /// <summary>
    /// IObjectCollection
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IObjectCollection<T> : IObjectCollectionBase
        where T : class, ICopiable<T>, IIdentifiable
    {
        /// <summary>
        /// Adds the specified item. base emthod for batch procressing
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        CollectionChangedEventArgs<T> AddItemBase(T item);

        /// <summary>
        /// Removes the item. For butch processing. Not thread safe.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        CollectionChangedEventArgs<T> RemoveItemBase(int index, T item);

        /// <summary>
        /// Adds the specified item. base emthod for batch procressing
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        CollectionChangedEventArgs<T> InsertToTopItemBase(T item);

        /// <summary>
        /// Updates the item. For butch processing. Not thread safe.
        /// </summary>
        /// <param name="oldItem">The old item.</param>
        /// <param name="newItem">The new item.</param>
        /// <returns></returns>
        CollectionChangedEventArgs<T> UpdateItemBase(T oldItem, T newItem);

        /// <summary>
        /// Finds the specified match.
        /// </summary>
        /// <param name="match">The match.</param>
        /// <param name="index">The index.</param>
        /// <returns>Index of first founded  intem</returns>
        T Find(Predicate<T> match, out int index);

        /// <summary>
        /// Called when [collection changed].
        /// </summary>
        /// <param name="e">The <see cref="CollectionChangedEventArgs{T}"/> instance containing the event data.</param>
        void OnCollectionChanged(CollectionChangedEventArgs<T> e);

        /// <summary>
        /// Gets the synch root.
        /// </summary>
        /// <value>The synch root.</value>
        object SynchRoot { get; }
    }
}